
import { _decorator, Component, instantiate, Node } from 'cc';
import { resManger } from '../tools/ResManger';
import { Loader } from '../tools/LoadManger';
const { ccclass, property } = _decorator;

@ccclass('UIManager')
export class UIManager extends Component {
    private mCurView: Node = null;
    start() {
        // [3]
    }

    ShowFight() {
        this.node.destroyAllChildren();
        this.ShowViewByName("Fight");
    }

    public ShowViewByName(fileName: string, back?) {
        if (this.mCurView) {
            this.node.removeAllChildren();
        }
            

        resManger.GetPrefabByKey(fileName, () => {
            this.mCurView = instantiate(Loader.GetPrefab(fileName));
            if (back) back();
            this.node.addChild(this.mCurView);
        });
    }
}

